<!doctype html>
<html lang="en">
<head>
    @include('web.layout.head')
    <link rel="stylesheet" href="{{mix('/css/web/user/return_goods.css')}}">
    <script src="{{mix('/js/web/frame/jedate/jquery.jedate.js')}}"></script>
    <link rel="stylesheet" href="{{mix('/js/web/frame/jedate/skin/jedate.css')}}">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

</head>
<body>

@include('web.layout.header')
@include('web.layout.user_tab')
<div class="base_member_content">
    <div class="w1200">
      @include('web.layout.seller_nav')
      <div class="nav_right fr">
        <div class="marryreal">
          <div class="name">
            <span class="goodsfabu">退货/款订单</span>
          </div>
          <div class="my-subnav f-cb">
              <ul>
                  <li @if(request('status',0) == '') class="cur" @endif><a href="{{asset('member/seller/change')}}">所有订单</a><i></i></li>
                  <li  @if(request('status',0) == 2) class="cur" @endif><a href="{{asset('member/seller/change?status=2')}}">已处理</a><i></i></li>
                  <li  @if(request('status',0) == 3) class="cur" @endif><a href="{{asset('member/seller/change?status=3')}}">未处理</a><i></i></li>
              </ul>
          </div>
          <div class="marryst">
            <form action="{{URL::current()}}" method="get">
              <span>下单时间</span>
              <input name="created_at[start]" class="datainp" id="inpstart" type="text" placeholder="开始日期" readonly="" value="{{array_get($search_params,'created_at.start')}}">
              <span>至</span>
              <input name="created_at[end]" class="datainp" id="inpend" type="text" placeholder="结束日期" readonly="" value="{{array_get($search_params,'created_at.end')}}">
              <input type="submit" class="buttonn" value="查询">
            </form>
          </div>

          <div class="table list">
              <table>
                  <thead>
                  <tr>
                      <th width="300">
                        <p class="oedername">订单商品 </p>
                      </th>
                      <th width="160">
                        <p>退货/款理由</p>
                      </th>
                      <th width="120">
                        <p>金额</p>
                      </th>
                      <th width="120">
                        <p>退货/款状态 </p>
                      </th>
                      <th width="150">
                        <p>操作</p>
                      </th>
                  </tr>
                  </thead>
              </table>
          </div>
          @foreach($list as $key=>$order)
          <div class="tablelist">
              <table>
                  <thead>
                  <tr>
                      <th>
                        <font>订单编号：{{$order['order_code']}}</font>
                      </th>
                      <th colspan="3">
                        <p>买家：<a>{{$order['user_name']}} </a></p>
                      </th>
                      <th width="150">
                        <span>下单时间：{{date('Y/m/d',strtotime($order['created_at']))}}</span>
                      </th>
                  </tr>
                  </thead>
                  <tbody>
                  
                  @foreach(array_get($order,'order_products') as $k=>$products)
                  @if($k==0)
                  <tr>
                      <td width="300">
                        <a class="img" target="_blank" href="/shop/detail/{{$products['product_id']}}">
                          <img width="70" height="70" src="{{$products['product_img_url']}}">
                        </a>
                        <span class="goodsname">
                          <a target="_blank" href="/shop/detail/{{$products['product_id']}}"> {{$products['product_name']}} </a>
                        </span>
                        <span class="goodsid">商品ID：{{$products['product_id']}}</span>
                      </td>
                      <td width="160" rowspan="{{$product_count = count($order['order_products'])}}">
                          <p> {{$order['resason']}} </p>
                      </td>
                      <td rowspan="{{$product_count}}" class="text-center" width="120">¥{{$products['product_money']}}</td>
                      <td rowspan="{{$product_count}}" class="text-center" width="120">
                        @if($order['status']==0) 
                          未处理
                        @elseif($order['status']==1) 
                          同意退款
                        @elseif($order['status']==2) 
                          同意退货/款
                        @elseif($order['status']==3) 
                          不同意退货/款
                        @elseif($order['status']==4) 
                          已确认收货
                        @elseif($order['status']==5) 
                          已完成退货/款
                        @else
                          已取消
                        @endif
                      </td>
                      <td rowspan="{{$product_count}}" class="text-center" width="150">
                          @if($order['status']==0)
                          <div class="a_disagree fl" data-id="{{$order['id']}}" data-status="3">不同意</div>
                          <div class="a_agree fl" data-id="{{$order['id']}}" data-status="{{$order['change_type']==0?1:2}}">同意</div>
                          @endif
                          <a class="a_details" href="/member/seller/orders/{{$order['id']}}">订单详情</a>
                          <div class="a_step fl" data-id="{{$order['id']}}">查看申请进度</div>
                      </td>
                  </tr>
                  @else
                  <tr>
                      <td width="300">
                        <a class="img" target="_blank" href="/shop/detail/{{$products['product_id']}}">
                          <img width="70" height="70" src="{{$products['product_img_url']}}">
                        </a>
                        <span class="goodsname">
                          <a target="_blank" href="/shop/detail/{{$products['product_id']}}"> {{$products['product_name']}} </a>
                        </span>
                        <span class="goodsid">商品ID：{{$products['product_id']}}</span>
                      </td>
                  </tr>
                  @endif
                  @endforeach
                  <tr class="base_content base_content{{$order['id']}}">
                      <td colspan="5">
                        <div class="order_state">
                            <ul class="order_finish">
                                <li class="order_first one">
                                    <h3 class="submit">提交订单</h3>
                                    <div class="spend">
                                        <p class="quan">1</p>
                                        <img class="quan1" src="{{asset('/img/web/user/dui.png')}}" alt="">
                                        <img class="green" src="{{asset('/img/web/user/left.png')}}" alt="">
                                    </div>
                                    <h4 class="order_day order_day1">{{ date('Y/m/d H:i',strtotime($order['created_at'])) }}</h4>
                                </li>
                                <li class="order_first second">
                                    <h3 class="submit">卖家同意</h3>
                                    <div class="spend">
                                        <p class="quan">2</p>
                                    @if($order['status'] > 0 && $order['status'] != 3)
                                            <img class="quan2" src="{{asset('/img/web/user/dui.png')}}" alt="">
                                            <img class="green_1" src="{{asset('/img/web/user/left.png')}}" alt="">
                                            <img class="green2" src="{{asset('/img/web/user/right.png')}}" alt="">
                                    </div>
                                    <h4 class="order_day order_day2">{{ date('Y/m/d H:i',strtotime($order['created_at'])) }}</h4>
                                    @else
                                    </div>
                                    @endif
                                </li>
                                <li class="order_first third">
                                    <h3 class="submit">退货/款中</h3>
                                    <div class="spend">
                                        <p class="quan">3</p>
                                    @if($order['status'] > 1 && $order['status'] != 3)
                                            <img class="quan3" src="{{asset('/img/web/user/dui.png')}}" alt="">
                                            <img class="green_2" src="{{asset('/img/web/user/left.png')}}" alt="">
                                            <img class="green4" src="{{asset('/img/web/user/right.png')}}" alt="">
                                    </div>
                                    <h4 class="order_day order_day3">{{ date('Y/m/d H:i',strtotime($order['created_at'])) }}</h4>
                                    @else
                                    </div>
                                    @endif
                                </li>
                                <li class="order_first fourth">
                                    <h3 class="submit">交易完成</h3>
                                    <div class="spend">
                                        <p class="quan">4</p>
                                    @if($order['status'] > 2 && $order['status'] != 3)
                                            <img class="quan4" src="{{asset('/img/web/user/dui.png')}}" alt="">
                                            <img class="green3" src="{{asset('/img/web/user/right.png')}}" alt="">
                                    </div>
                                    <h4 class="order_day order_day4">{{ date('Y/m/d H:i',strtotime($order['created_at'])) }}</h4>
                                    @else
                                    </div>
                                    @endif
                                </li>
                            </ul>
                        </div>
                      </td>
                  </tr>
                  </tbody>
              </table>
          </div>
          @endforeach
          <div class="marryreal">
              @include("web.common.paginate")
          </div>
        </div>
      </div>
    </div>

</div>
@include('web.layout.footer')
<script type="text/javascript">
  var start = {
      format: 'YYYY-MM-DD hh:mm',
      minDate: '2014-06-16 23:59:59', //设定最小日期为当前日期
      //festival:true,
      maxDate: $.nowDate({DD:0}), //最大日期
      choosefun: function(elem,datas){
          end.minDate = datas; //开始日选好后，重置结束日的最小日期
          endDates();
      },
      okfun:function (elem,datas) {
          alert(datas)
      }
  };
  var end = {
      format: 'YYYY-MM-DD hh:mm',
      minDate: $.nowDate({DD:0}), //设定最小日期为当前日期
      //festival:true,
      maxDate: '2099-06-16 23:59:59', //最大日期
      choosefun: function(elem,datas){
          start.maxDate = datas; //将结束日的初始值设定为开始日的最大日期
      }
  };
  function endDates() {
      end.trigger = false;
      $("#inpend").jeDate(end);
  }
  $("#inpstart").jeDate(start);
  $("#inpend").jeDate(end);

  $(function(){
    $('.a_disagree').click(function(){
        var id = $(this).attr('data-id');
        var status = $(this).attr('data-status');
        layer.confirm('确定不同意？', {
            btn: ['确认', '取消'] //可以无限个按钮
        }, function (index) {
            $.ajax({
                url: '{{URL::current()}}/'+id,
                type: 'post',
                dataType: 'json',
                data: {'id': id,'status':status},
                success: function (data) {
                    if (0 == data.code) {
                        layer.alert('操作成功', {
                            icon: 1
                        }, function () {
                            location.reload();
                        });
                    } else {
                        layer.alert('操作失败', {
                            icon: 2
                        });
                    }
                }
            });
        }, function (index, layero) {
            layer.close(index);
        });
    })

    $('.a_agree').click(function(){
        var id = $(this).attr('data-id');
        var status = $(this).attr('data-status');
        layer.confirm('确定同意？', {
            btn: ['确认', '取消'] //可以无限个按钮
        }, function (index) {
            $.ajax({
                url: '{{URL::current()}}/'+id,
                type: 'post',
                dataType: 'json',
                data: {'id': id,'status':status},
                success: function (data) {
                    if (0 == data.code) {
                        layer.alert('操作成功', {
                            icon: 1
                        }, function () {
                            location.reload();
                        });
                    } else {
                        layer.alert('操作失败', {
                            icon: 2
                        });
                    }
                }
            });
        }, function (index, layero) {
            layer.close(index);
        });
    })

    $('.a_step').click(function(){
      var id = $(this).attr('data-id');
      $('.base_content'+id).show();
    })

  })


</script>
</body>
</html>